package com.cgt.day6;

import org.junit.Test;

public class Exercise {
    @Test
    public void test1(){
        String str1 = "Java Study";
        String str11 = new String("Java Study");
        String str111 = "Java Study";
        String str2 = "java study";
        String str3 = "j a v a  s t u d y";
        String str4 = "j:a:v:a:s:t:u:d:y";
        String str5 = "   Java Study   ";
        String str6 = "ABC";
        String str7 = "DEF";
        String str8 = "GHI";
        String str9 = "JKL";

        System.out.println(str1 == str11);
        System.out.println(str11 == str111);
        System.out.println(str111 == str1);
        System.out.println(str1.equals(str11));
        System.out.println(str11.equals(str111));
        System.out.println(str111.equals(str1));

        System.out.println(str1.length());
        System.out.println(str1.charAt(0));

        System.out.println(str1.indexOf('a'));
        System.out.println(str1.indexOf('a', 2));
        System.out.println(str1.indexOf("va"));
        System.out.println(str1.indexOf("va", 3));

        System.out.println(str1.lastIndexOf('a'));
        System.out.println(str1.lastIndexOf('a', 2));
        System.out.println(str1.lastIndexOf("va"));
        System.out.println(str1.lastIndexOf("va", 1));

        System.out.println(str1.equals(str2));
        System.out.println(str1.equals(str11));
        System.out.println(str1.equalsIgnoreCase(str2));

        System.out.println(str1.contains("Java"));
        System.out.println(str2.contains("Java"));
        System.out.println(str1.startsWith("Java"));
        System.out.println(str1.startsWith("Java", 2));
        System.out.println(str1.endsWith("udy"));
    }

    @Test
    public void test2(){
        int num = 1;
        String str = new String("123");
//        System.out.println(getClass(str));
//        System.out.println(getClass(num));
        System.out.println(Integer.toString(2));
    }

    @Test
    public void test3(){
        String str1 = "Java ";
        String str2 = "PHP ";
        String str3 = "Python ";
        String str4 = "UI ";
        String str5 = str1 + str2 + str3 +str4;
//        System.out.println(str5);

        StringBuffer buffer = new StringBuffer("BF ");
        buffer.append(str1).append(str2).append(str3).append(str4);
        System.out.println(buffer);

        StringBuilder builder = new StringBuilder("BD ");
        builder.append(str1).append(str2).append(str3).append(str4);
        System.out.println(builder);
    }
}
